//
//  SubmitOrderViewController.m
//  MaJangJi
//
//  Created by 嗯，大葱 on 16/9/10.
//  Copyright © 2016年 嗯，大葱. All rights reserved.
//

#import "SubmitOrderViewController.h"
#import "Third10TableViewCell.h"
#import "Third11TableViewCell.h"
#import "FangAn1TableViewCell.h"
#import "FN4TableViewCell.h"
#import "Third12TableViewCell.h"
#import "FN5TableViewCell.h"
#define k_Width      [UIScreen mainScreen].bounds.size.width

#define h_Height     [UIScreen mainScreen].bounds.size.height
@interface SubmitOrderViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic, strong)UITableView *tableView;
@end

@implementation SubmitOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNaVBar];
    [self configureViewController];
    
}
#pragma mark 配置导航栏以及控制器视图
- (void)setNaVBar {
    self.navigationItem.title = @"提交订单";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStylePlain) target:self action:@selector(handleBack2)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"问"] style:(UIBarButtonItemStylePlain) target:self action:@selector(handleWenAction)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor grayColor];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor grayColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    
//    UIView *statusBarView=[[UIView alloc] initWithFrame:CGRectMake(0, -20, k_Width, 20)];
//    statusBarView.backgroundColor=[UIColor colorWithRed:82/255.0 green:82/255.0 blue:82/255.0 alpha:1.0];
//    [self.navigationController.navigationBar addSubview:statusBarView];
}
//- (UIStatusBarStyle)preferredStatusBarStyle {
//    return UIStatusBarStyleLightContent;
//}
- (void)configureViewController {
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.view.backgroundColor = [UIColor whiteColor];
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, k_Width, h_Height) style:(UITableViewStylePlain)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    
    self.tableView.allowsSelection = NO;
    [self.tableView registerNib:[UINib nibWithNibName:@"Third10TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell10"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"Third11TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell11"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"FangAn1TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell1"];

     [self.tableView registerNib:[UINib nibWithNibName:@"FN4TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell4"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"Third12TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell12"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"FN5TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell5"];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 8;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    }
    if (section == 1) {
          return 1;
    }
    if (section == 2) {
          return 2;
    }
    if (section == 3) {
        return 5;
    }
    if (section == 4) {
        return 1;
    }
    if (section == 5) {
        return 1;
    }
    if (section == 6) {
        return 3;
    }
    if (section == 7) {
        return 1;
    }else {
        return 0;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        Third10TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell10"];
        return cell;
    }
    
   else if (indexPath.section == 1) {
        Third11TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell11"];
       [cell.turnToAddressBtn addTarget:self action:@selector(handleTurnToAddressBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
        return cell;
       
   }else if (indexPath.section == 5){
       FN4TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell4"];
       return cell;
   }
   
   else if (indexPath.section == 6){
       if (indexPath.row == 2) {
            Third12TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell12"];
           cell.nameLabel.text = @"付款方式";
           [cell.cusBtn setImage:[UIImage imageNamed:@"444"] forState:(UIControlStateNormal)];
           [cell.cusBtn addTarget:self action:@selector(handleChoosePayBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
           return cell;
       }
       else {
           Third10TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell10"];
           if (indexPath.row == 0) {
               cell.nameLabel.text = @"运费(送货)";
               cell.timeLabel.text = @"¥25";
           }
           if (indexPath.row == 1) {
               cell.nameLabel.text = @"预计总价";
               cell.timeLabel.text = @"¥28902";
           }
           
           return cell;
       }
       
      
   }
   else if (indexPath.section ==7){
       Third12TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell12"];
       cell.nameLabel.text = @"预计支付¥66666作为定金";
       [cell.cusBtn setImage:[UIImage imageNamed:@"333"] forState:(UIControlStateNormal)];
       [cell.cusBtn addTarget:self action:@selector(handleSubmitOrderBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
       return cell;
   }
   else if (indexPath.section == 3){
       if (indexPath.row == 0) {
           FN5TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell5"];
           return cell;
       }else {
           FangAn1TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
           if (indexPath.row == 1) {
               cell.nameLabel.text = @"麻将桌";
               cell.moneyLabel.text = @"¥1111";
               cell.countLabel.text = @"x10";
           }
           if (indexPath.row == 2) {
               cell.nameLabel.text = @"转盘";
               cell.moneyLabel.text = @"¥123";
               cell.countLabel.text = @"x1";
           }
           if (indexPath.row == 3) {
               cell.nameLabel.text = @"椅子";
               cell.moneyLabel.text = @"¥321";
               cell.countLabel.text = @"x4";
           }
           if (indexPath.row == 4) {
               cell.nameLabel.text = @"水晶牌";
               cell.moneyLabel.text = @"413";
               cell.countLabel.text = @"x2";
           }
           
           return cell;
       }
   }
   
   else {
        FangAn1TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
       if (indexPath.section == 2) {
           if (indexPath.row == 0) {
               cell.nameLabel.text = @"施工门店";
               cell.moneyLabel.text = @"珺墨网络科技";
           }
           if (indexPath.row == 1) {
               cell.nameLabel.text = @"施工面积";
               cell.moneyLabel.text = @"200平米";
           }
       }
       if (indexPath.section == 4) {
           cell.nameLabel.text = @"设计费";
           cell.moneyLabel.text = @"¥666";
       }
      
        return cell;
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 1) {
        return 77;
    }if (indexPath.section ==5) {
        return 80;
    }
    
    else {
        return 40;
    }
}




#pragma mark 导航栏按钮点击事件
- (void)handleBack2 {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)handleWenAction {
    
    
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark cell里面按钮的点击事件
- (void)handleTurnToAddressBtnAction: (UIButton *)sender {
    [self showLog:@"click me will jump to yourself address view "];
}

- (void)handleChoosePayBtnAction: (UIButton *)sender {
    [self showLog:@"ni can choose your payment, if you click me"];
}

- (void)handleSubmitOrderBtnAction: (UIButton *)sender {
    [self showLog:@"I am submit order button "];
}






- (void)showLog:(NSString *)message {
    UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"please see the message" message:message delegate:self cancelButtonTitle:@"cencle" otherButtonTitles:@"sure", nil];
    [alter show];
}


















@end
